        var unDrawBackStore = new Ext.data.JsonStore({
    		url: '/weihe/getList_unDb',
			root: 'datas',
			fields : [{
			        	   name:'UnDrawBackId',mapping:'id'
			          },{
			        	   name:'UnDrawBackCode',mapping:'code' 
			          },{
			        	   name:'UnDrawBackTaxSum',mapping:'taxSum' 
			          },{
        				   name:'UnDrawBackTab',mapping:'tab'
        			  },{
        				   name:'UnDrawBackReason',mapping:'reason'
        			  },{
        				   name:'UnSubmitDate',mapping:'submitDate',type : 'date', dateFormat:"Y-m-d"
        			  }],
						listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_unDb',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
        
        var drawBackStore = new Ext.data.JsonStore({
    		url: '/weihe/getList_drawBack',
			root: 'datas',
			fields : [{
			        	   name:'DrawBackId',mapping:'id'
			          },{
			        	   name:'DrawBackCode',mapping:'code' 
			          },{
			        	   name:'DrawBackSum',mapping:'sum' 
			          },{
			        	   name:'DrawBackDays',mapping:'days' 
			          },{
			        	   name:'DrawBackTax',mapping:'tax' 
			          },{
        				   name:'DrawBackDate',mapping:'drawBackDate',type : 'date', dateFormat:"Y-m-d"
        			  }],
						listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_drawBack',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
        
      
       
        
drawBacks = function(){
	
	var tmp='';

	
  return{
	  
  drawBackGrid : function(){
	  
		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : unDrawBackStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});


		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		   
	   var listGrid = new Ext.grid.GridPanel({
		   id:'unDrawBackGrid',
		   region : 'north',
		   height : 300,
		   minColumnWidth : 35,
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : unDrawBackStore,
		   columns: [
		             {header : '接单号', dataIndex : 'UnDrawBackCode'},
		             {header : '税金', dataIndex : 'UnDrawBackTaxSum'},
		             {header : '未退原因', dataIndex : 'UnDrawBackReason'}
		             ],
         sm : rowSelectionModel,
         listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   		var record = grid.getStore().getAt(rowIndex);
			   		if(record.get('UnDrawBackCode') == '合计'){
			   			 Ext.Msg.alert('提示','不能编辑合计项!');
			   		}else{
			   		tmp = record.id;
			   		Ext.getCmp("drawBackForm").form.findField('drawBack.code').setValue(record.get('UnDrawBackCode'));
			   		Ext.getCmp("drawBackForm").form.findField('drawBack.tax').setValue(record.get('UnDrawBackTaxSum'));
			   		Ext.getCmp("drawBackForm").buttons[0].enable();
					Ext.getCmp("drawBackForm").buttons[1].enable();
					Ext.getCmp("drawBackForm").buttons[2].enable();
		   		}
			   }
		   },
		  bbar : pageToolBar
});
		return listGrid;
	},
  
    grid : function(){
	 

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 5,
			store : drawBackStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		   


		});


		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		   
	   var grid = new Ext.grid.GridPanel({
		   id:'drawBackGrid',
		   title : '退税信息表',
		   region : 'center',
		   minColumnWidth : 50,
		   loadMask : {msg:'正在加载数据，请稍侯...'}, // 单击分页时显示,为true显示'Loading...'
		   store : drawBackStore,
		   columns: [
		   			  {header : '接单号', dataIndex : 'DrawBackCode'},
		             {header : '退税日期', dataIndex : 'DrawBackDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y-m-d')},
		             {header : '退税时长(天)', dataIndex : 'DrawBackDays'},
		             {header : '退税金额', dataIndex : 'DrawBackTax'},
		             {header : '退税累计', dataIndex : 'DrawBackSum'}
          ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   Ext.getCmp("drawBackForm").form.loadRecord(record);
			   Ext.getCmp("drawBackForm").buttons[0].enable();
			   Ext.getCmp("drawBackForm").buttons[1].enable();
			   Ext.getCmp("drawBackForm").buttons[2].enable();
			   Ext.getCmp("drawBackForm").buttons[0].setText('修改');
			  
		   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return grid;
	},
	drawBackForm : function(){
		
		

		var button_add = new Ext.Button({
			text : '添加',
			disabled : true,
			handler : function() {
				if(drawBackForm.form.isValid()){
					progressConsole();
					if(drawBackForm.form.findField("drawBack.id").getValue() == "" || drawBackForm.form.findField("drawBack.code").getValue() == ""){
						drawBackForm.form.submit({
							  url : '/weihe/add_drawBack',
							   success : function(form, action) {
								if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										 drawBackForm.form.reset();
										 Ext.getCmp("drawBackForm").buttons[0].disable();
			   						     Ext.getCmp("drawBackForm").buttons[1].disable();
			   						     Ext.getCmp("drawBackForm").buttons[2].disable();
										 Ext.getCmp("unDrawBackGrid").getStore().reload();
										 Ext.getCmp("drawBackGrid").getStore().load({params : {start : action.result.total-1, limit : 5}});
									});
								  }
							    },
							    failure : function(form, action) {
	      							Ext.Msg.alert('错误', action.result.msg);
	      						}
						    });
					}else{
						drawBackForm.form.submit({
							  url : '/weihe/update_drawBack',
							   success : function(form, action) {
								if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										drawBackForm.form.reset();
										 Ext.getCmp("drawBackGrid").getStore().reload();
										 drawBackForm.buttons[0].setText('添加');
										 Ext.getCmp("drawBackForm").buttons[0].disable();
			   						     Ext.getCmp("drawBackForm").buttons[1].disable();
			   						     Ext.getCmp("drawBackForm").buttons[2].disable();
									});
								  }
							    },
							    failure : function(form, action) {
	      							Ext.Msg.alert('错误', action.result.msg);
	      						}
						    });
					}
				}else{
					Ext.Msg.alert('提示','请输入相关内容');
				}
			}
		
			
		});

	var button_clear = new Ext.Button({
		text : '清空',
		disabled : true,
		handler : function() {
		     drawBackForm.form.reset();
		      Ext.getCmp("drawBackForm").buttons[0].disable();
			  Ext.getCmp("drawBackForm").buttons[1].disable();
			  Ext.getCmp("drawBackForm").buttons[2].disable();
		     drawBackForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		disabled : true,
		handler : function() {
			var id = drawBackForm.form.findField("drawBack.id").getValue()
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				drawBackForm.form.submit({
					  url : '/weihe/delete_drawBack',
					   success : function(form, action) {
						 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
						}else{
							Ext.Msg.alert('消息', action.result.msg, function() {
								 drawBackForm.form.reset();
								 Ext.getCmp("unDrawBackGrid").getStore().reload();
								 Ext.getCmp("drawBackGrid").getStore().load({params : {start : 0, limit : 5}});
								 drawBackForm.buttons[0].setText('添加');
								 Ext.getCmp("drawBackForm").buttons[0].disable();
			   					 Ext.getCmp("drawBackForm").buttons[1].disable();
			   					 Ext.getCmp("drawBackForm").buttons[2].disable();
							});
						  }
					    },
					    failure : function(form, action) {
							Ext.Msg.alert('错误', action.result.msg);
						}
				    });
			}
		}
	});
	
		var drawBackForm = new Ext.form.FormPanel({
			id : 'drawBackForm',
			title : '退税信息',
			frame : true,
			width : 310,
			region : 'east',
			autoScroll : true,
			collapseMode :'mini',
			collapsible : true,
			labelAlign : 'right',
			labelWidth : 70,
			defaultType : 'textfield',
				defaults : {
				width : 200
			},
			items : [{
					id: 'DrawBackId',
					xtype : 'hidden',
					name : 'drawBack.id'
				},{
					id:'DrawBackCode',
					xtype : 'hidden',
					name : 'drawBack.code'
			    },{ 
				id: 'DrawBackDate',
				xtype: 'datefield',
                fieldLabel: "退税日期",
                format : 'Y-m-d',
                name: 'drawBack.drawBackDate'
			},{
				id:'DrawBackTax',
				fieldLabel : '退税金额',
				readOnly : true,
				name : 'drawBack.tax'
			},{
				id:'DrawBackDays',
				fieldLabel : '退税时长',
				name : 'drawBack.days',
				regex : /^[1-9]\d*$/,
			    regexText:'请输入有效的数量'      
			
			}],
			buttons : [button_add,button_clear,button_del]
		
	});
		return drawBackForm;
	}
  }
}();








